package com.omt.tarjimdinek.printer;

import javax.inject.Named;

import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.format.Printer;

/**
 * This is a base class so the {@link TypeAwarePrinter} can get all {@link Printer} with their corresponding types.
 *
 * @see Printer
 */
@Named("discoverablePrinter")
public abstract class DiscoverablePrinter<T> implements Printer<T> {

    private final Class<T> clazz;

    public DiscoverablePrinter(Class<T> clazz) {
        this.clazz = clazz;
    }

    public Class<T> getTarget() {
        return clazz;
    }

    public String print(T document) {
        return print(document, LocaleContextHolder.getLocale());
    }
}